﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace CarEdge.Service.Interface
{
    public interface I_Base_EFCore<T> where T : class,new()
    {
        /// <summary>
        /// 条件查询
        /// </summary>
        /// <param name="where"></param>
        /// <returns></returns>
        IQueryable<T> QueryAll(Expression<Func<T,bool>>?where=null);
        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="type"></typeparam>
        /// <param name="isAsc"></param>
        /// <param name="order"></param>
        /// <param name="where"></param>
        /// <returns></returns>
        IQueryable<T> QueryAll<type>(bool isAsc, Expression<Func<T, type>> order, Expression<Func<T, bool>>? where = null);
        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="type"></typeparam>
        /// <param name="total"></param>
        /// <param name="page"></param>
        /// <param name="limit"></param>
        /// <param name="isAsc"></param>
        /// <param name="order"></param>
        /// <param name="where"></param>
        /// <returns></returns>
        IQueryable<T> QueryAll<type>(out int total, int page, int limit, bool isAsc, Expression<Func<T, type>> order, Expression<Func<T, bool>>? where = null);

        /// <summary>
        /// 新增单个实体
        /// </summary>
        /// <param name="entity"></param>
        void Add(T entity);
        /// <summary>
        /// 新增多个
        /// </summary>
        /// <param name="ie"></param>
        void AddRange(IEnumerable<T> ie);
        /// <summary>
        /// 修改单个实体
        /// </summary>
        /// <param name="entity"></param>
        void Update(T entity);

        void UpdateRange(IEnumerable<T> ie);
        /// <summary>
        /// 删除单个实体
        /// </summary>
        /// <param name="entity"></param>
        void Delete(T entity);
        /// <summary>
        /// 删除多个
        /// </summary>
        /// <param name="ie"></param>
        void DeleteRange(IEnumerable<T> ie);
        /// <summary>
        /// 保存
        /// </summary>
        /// <returns></returns>
        int SaveChanges();

    }
}
